<template>
	<!-- 弹出可输入文字的对话框 -->
	<view id="bohui" v-show="isShow">
		<view id="confrimBox">
			<view class="header">
				<text>{{title}} </text>
			</view>
			<view class="content">

				<view class="query-input">
					<!-- <input type="text" v-model="FormData.DEPTNAME" placeholder="部门" /> -->
					<lin-select :list="productList1" :loading="loading" loading-text="数据加载中" value-key="FullName"
						name-key="FullName" max-height="180" placeholder="请输入部门" @input="selectBM"
						v-model="FormData.DEPTNAME" />
				</view>

				<view class="query-input" v-if="queryType ==1">
					<!-- <input type="text" v-model="FormData.VNAME" placeholder="设备" /> -->
					<lin-select :list="productList2" :loading="loading" loading-text="数据加载中" value-key="EQBOMNAME"
						name-key="EQBOMNAME" max-height="180" placeholder="请输入设备" @input="selectSB"
						v-model="FormData.VNAME" />
				</view>

				<view class="query-input p-20">
					<input type="text" v-model="FormData.MATERIALNAME " placeholder="物资名称" />
				</view>
				<view class="query-input p-20">
					<input type="text" v-model="FormData.MATSPEC " placeholder="规格型号" />
				</view>
				<view class="query-input p-20">
					<input type="text" v-model="FormData.APPLYER " :placeholder=" queryType ==1 ?'归集人':'领用人' " />
				</view>

			</view>

			<view class="footer">
				<view @click="hide" class="cancel rightBorder">取消</view>
				<view @click="define" class="enter">确定</view>
			</view>
		</view>
	</view>
</template>

<script>
	// 
	export default {
		props: {
			isShow: {
				type: Boolean,
				default () {
					return false
				}
			},
			title: {
				type: String,
				default () {
					return "请输入"
				}
			},
			queryType: {}

		},
		data() {
			return {
				FormData: {
					VNAME: '',
					MATERIALNAME: "",
					MATSPEC: "",
					DEPTNAME: "",
					APPLYER: "",
				},
				loading: false,
				productList1: [],
				productList2: []
			};
		},
		methods: {
			hide() {
				this.$emit('cancelModal')
			},
			define() {
				this.hide();
				this.$emit('okModal', this.FormData);
			},
			selectBM(val) {
				let requestData = {
					"QueryType": 0,
					"VNAME": val,
					"account": "",
					"category": "BA_DEPARTMENT",
					"comboboxId": "",
					"keyword": "",
					"organizeId": "",
					"queryJson": {
						"VNAME": val,
						"keyword": val
					},
				}
				this.axios({
						url: '/api/APPCommon/GetBasicData',
						data: requestData,
						isLoading: 1
					})
					.then((res) => {
						this.productList1 = res.Result
					})
			},

			selectSB(val) {
				let requestData = {
					"page": 1,
					"rows": 1000,
					"IsPage": "false",
					"queryJson": {
						"PK_ORG": "",
						"VNAME": val,
						"keyword": val
					}
				}
				this.axios({
						url: '/API/APPCommon/GetEquipmentData',
						data: requestData,
						isLoading: 1
					})
					.then((res) => {
						this.productList2 = res.Result.rows
					})
			}

		}
	}
</script>

<style lang="scss" scoped>
	.is-input-border {
		border: none !important;
	}

	#bohui {
		position: fixed;
		top: 0;
		left: 0;
		width: 100vw;
		height: 100vh;
		z-index: 100;
		background-color: rgba(0, 0, 0, .5);
		// display: flex;
		// align-items: center;
		// justify-content: space-around;
	}

	#confrimBox {
		width: 85%;
		border-radius: 20rpx;
		background-color: #FFFFFF;
		overflow: hidden;
		// margin-top: -50vh;
		position: relative;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);

		.header {
			display: block;
			text-align: center;
			font-size: 32rpx;
			padding: 20rpx;
			border-bottom: 1rpx solid #f5f5f5;

			text {
				text-align: center;
				font-size: 32rpx;
			}
		}

		.content {
			padding: 20rpx 60rpx 30rpx;

			uni-textarea {
				width: 100%;
				height: 120rpx;
				padding: 4rpx;
				font-size: 18rpx;
			}
			.p-20{
				margin: 20rpx 0;
				padding: 20rpx 0;
			}

			.query-input {
				
				border-bottom: 1rpx solid #F1F1F1;
				input {
					font-size: 20rpx;
					padding-left: 30rpx;
					line-height: 30rpx;
				}
			}

			.query-input:focus-within {
				border-bottom: 1rpx solid #1677FF;
			}
		}

		.footer {
			display: flex;
			align-items: center;
			flex-wrap: nowrap;
			justify-content: space-between;
			border-top: 2rpx solid #f5f5f5;

			view {
				width: 50%;
				text-align: center;
				padding: 20rpx;
				font-size: 32rpx;
			}

			view:active {
				background-color: rgba($color: $uni-bg-color-grey, $alpha: 1);
			}

			.rightBorder {
				position: relative;
			}

			.rightBorder:after {
				content: "";
				width: 2rpx;
				height: 100%;
				background-color: $uni-bg-color-grey;
				position: absolute;
				top: 0;
				right: 0;
			}

			.cancel {
				color: $uni-text-color-grey;
			}

			.enter {
				color: $uni-color-primary;
			}
		}
	}
</style>